import React, { useEffect, useState } from 'react'
import http from '../../utils/http'
import { useParams } from 'react-router-dom'
import { ProductCard } from 'react-vant';
import { NavBar } from 'antd-mobile'
import { useNavigate } from 'react-router-dom';
function Index() {
  const { id } = useParams()
  const navigate = useNavigate()
  const [list, setList] = useState({})
  const getList = async () => {
    const res = await http.get('/api/list/detail', {
      params: {
        id,
      }
    })

    console.log(res);

    const { code, data } = res.data

    if (code === 200) {
      setList(data)
    }

  }

  useEffect(() => {
    getList()
  }, [])
  return (
    <div>
      <NavBar onBack={()=>navigate(-1)}>详情页</NavBar>
      <ProductCard
        num={list.date}
        price={list.price}
        desc={list.title}
        title={list.id}
        thumb={list.image}
      />
    </div>
  )
}

export default Index
